//
//  DKRegisterHttp.m
//  DanKU
//
//  Created by 吴斌 on 2023/10/1.
//

#import "DKRegisterHttp.h"
#import "DKRegisterPhoneExistModel.h"
#import "DKRegisterUserModel.h"
@implementation DKRegisterHttp
//判断手机号是否存在
+(void)apiPhoneExistForAPI:(NSDictionary *)param complete:(void(^)(BOOL isPhoneExist))complete{
    [[DKHttpHelper request] POST:[NSString getServiceUrl:DK_PhoneExist] params:param withJson:false withIsLoad:YES success:^(NSInteger status, id  _Nonnull data) {
        NSDictionary *phoneExistDic = [data objectForKey:@"data"];
        DKRegisterPhoneExistModel *dkRegisterPhoneExistMdl = [DKRegisterPhoneExistModel mj_objectWithKeyValues:phoneExistDic];
        complete(dkRegisterPhoneExistMdl.exist);
    }failure:^(NSInteger status, NSString * _Nonnull msg) {
        
    }];
}
//注册用户
+(void)apiRegisterUserForAPI:(NSDictionary *)param complete:(void(^)(void))complete failure:(void(^)(NSString * msg))failure{
    [[DKHttpHelper request] POST:[NSString getServiceUrl:DK_RegisterUser] params:param withJson:true withIsLoad:YES success:^(NSInteger status, id  _Nonnull data) {
        NSDictionary *dkRegisterUserDic = [data objectForKey:@"data"];
        DKRegisterUserModel *dkRegisterUserMdl = [DKRegisterUserModel mj_objectWithKeyValues:dkRegisterUserDic];
        dkRegisterUserMdl.phone = [param objectForKey:@"loginName"];
        [DKGlobalHelper saveRegisterUserInfo:dkRegisterUserMdl];
        //打点
        [[DKAdjustHelper defaultManager] adjustUserRegister];
        complete();
    }failure:^(NSInteger status, NSString * _Nonnull msg) {
        failure(msg);
    }];
}
@end
